package reznic.ga.tracker.objects;

import reznic.ga.tracker.utils.StringUtils;

/**
 *
 * &t=item // Item hit type.<br>
 * &ti=12345 // Transaction ID. Required.<br>
 * &in=sofa // Item name. Required.<br>
 * &ip=300 // Item price.<br>
 * &iq=2 // Item quantity.<br>
 * &ic=u3eqds43 // Item code / SKU.<br>
 * &iv=furniture // Item variation / category.<br>
 * &cu=EUR // Currency code.<br>
 *
 * @author Reznic Alexandru <reznic.a@gmail.com>
 */
public class TrackItem {

    private final String transactionID;
    private final String itemName;

    public TrackItem(String transactionID, String itemName) {
        this.transactionID = transactionID;
        this.itemName = itemName;
    }

    public String buildURL() {
        StringBuilder buf = new StringBuilder();
        if (StringUtils.isBlank(transactionID) || StringUtils.isBlank(itemName)) {
            throw new NullPointerException("transactionID and itemName is Required");
        }
        buf.append("&ti=").append(transactionID);
        buf.append("&in=").append(itemName);

        return buf.toString();
    }
}
